import Vue from 'vue'
import VueRouter from 'vue-router'

import mainRouter from './modules/mainRouter'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/',
    component: () => import('../layouts/framework.vue'),
    meta: {
      title: '自述文件'
    },
    children: [
      ...mainRouter
    ]
  },
  {
    path: '/login',
    component: () => import('../views/common/login.vue')
  },
  {
    path: '/404',
    component: () => import('../views/common/404.vue')
  },
  {
    path: '/403',
    component: () => import('../views/common/403.vue')
  },
  {
    path: '*',
    redirect: '/404'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next)=>{
  next();
  // const token = ''
  // if(token){
  //   next();
  // }else{
  //   next('/login');
  // }
})

export default router
